import request from '@/utils/request'

/**
 * 获取结算信息
 */
export const findCheckoutInfo = () => {
  return request('/member/order/pre', 'get')
}

/**
 * 添加新的地址信息或者修改地址信息
 * @param {Object} address--地址信息
 * @returns Promise
 */
export const addAddress = (address) => {
  return request('/member/address', 'post', address)
}

/**
 * 修改地址信息
 * @param {Object} address--修改的地址信息
 * @returns Promise
 */
export const editAddress = (address) => {
  return request(`/member/address/${address.id}`, 'put', address)
}

/**
 * 提交订单信息
 */
export const submitOrder = (params) => {
  return request('/member/order', 'post', params)
}

/**
 * 获取我的订单详情
 * @param {String} id
 * @returns Promise
 */
export const findOrderDetail = (id) => {
  return request(`/member/order/${id}`, 'get')
}
